$(function(){
		/*初始化表格*/
		$('#planeBase').datagrid({
    		url:'backplanebasejson',
    		collapsible:true,
    		fit:true,
			fitColumns:true,
			toolbar:'#footer',
			pagination:true,
			pageSize:20,
			pageList:[20,50,100,200],
			remoteSort:false,
   			columns:[[
   			 	{field:'ck',checkbox:true},
   			 	{field:'planeID',hidden:'true'},
			{field:'planeName',title:'航班名称',align:'center',width:'20%'},
				{field:'orgName',title:'航空公司名称',align:'center',width:'20%'},
				{field:'travelOrgName',title:'所属旅行社名称',align:'center',width:'20%'},
				{field:'memo',title:'备注',align:'center',width:'38%'}
    		]]
		});
			
});

/*搜索*/
function searchPlaneBase(){
	
		var planeName = $("#searchPlaneName").val();
	var planeOrgName = $("#searchPlaneOrgName").val(); 
		var travelOrgName = $("#searchTravelOrgName").val(); 
		$("#planeBase").datagrid("load",{
			planeName:planeName,
			planeOrgName:planeOrgName,
			travelOrgName:travelOrgName
		})
	}
	
/*清空*/
function clearPlaneBase(){
        $("#searchPlaneName").val('');
		$("#searchPlaneOrgName").val('');
	$("#searchTravelOrgName").val('');
     }


// 修改航班信息
function updatePlaneBase() {
	
	
		var rows = $('#planeBase').datagrid('getSelections');
		var checkNum = rows.length;
		if(checkNum==0){
			$.messager.alert('错误','至少选择一项','error');
		 } else if(checkNum>1){
			$.messager.alert('错误','最多选择一项','error');
		 }else{
			//判断创建人所属公司是否相同  登陆人与创建人公司相同
			var travelOrgID = rows[0].spare1;
			var sessionOrgID=$("#sessionOrgID").val();
			if(parseInt(travelOrgID)==parseInt(sessionOrgID)){
		$.messager.confirm('Confirm', '确定要修改吗?', function(r){
	if (r){
		var iPlaneID = rows[0].planeID; 
		 	location.href="/mmy/toupdateplanebase?iPlaneID="+iPlaneID;
	}
});
	}else{
		$.messager.alert('错误','无法修改','error');
		
	}	
		 }
}



/*进入航班时刻页面*/
function toPlanePlan(){
	var rows = $('#planeBase').datagrid('getSelections');
		var checkNum = rows.length;
		if(checkNum==0){
			$.messager.alert('错误','至少选择一项','error');
		 } else if(checkNum>1){
			$.messager.alert('错误','最多选择一项','error');
		 }else{
				var iPlaneID = rows[0].planeID;  
				location.href="/mmy/backtoplaneplanindex?iPlaneID="+iPlaneID;
			}
}

